- Doing the plot year by year
#Unstacking the series level to control for the boxplot
data_to_plot2 = data_to_plot.reset_index(level = 1) # filling year into a series
data_to_plot2 = data_to_plot2.loc[:,data_to_plot2.columns != "Series"] # Dropping Series
plt.figure();
fig, axs = plt.subplots(3,2, figsize = (9,5), sharey=False)
data_to_plot2.boxplot(by = "year", ax = axs)
## array([<matplotlib.axes._subplots.AxesSubplot object at 0x0000000033797B38>,
## <matplotlib.axes._subplots.AxesSubplot object at 0x000000003371ADD8>,
## <matplotlib.axes._subplots.AxesSubplot object at 0x00000000337A47F0>,
## <matplotlib.axes._subplots.AxesSubplot object at 0x0000000030928C18>,
## <matplotlib.axes._subplots.AxesSubplot object at 0x000000003095AF98>,
## <matplotlib.axes._subplots.AxesSubplot object at 0x0000000030995358>],
## dtype=object)
##
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\pandas\plotting\_matplotlib\boxplot.py:391: UserWarning: When passing multiple axes, sharex and sharey are ignored. These settings must be specified when creating axes
## **kwds,
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
## return array(a, dtype, copy=False, order=order)
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
## return array(a, dtype, copy=False, order=order)
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
## return array(a, dtype, copy=False, order=order)
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
## return array(a, dtype, copy=False, order=order)
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
## return array(a, dtype, copy=False, order=order)
## C:\Users\gr114\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\numpy\core\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
## return array(a, dtype, copy=False, order=order)
for ax in fig.axes:
plt.sca(ax)
plt.xticks(rotation=45)
## (array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), <a list of 16 Text major ticklabel objects>)
## (array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), <a list of 16 Text major ticklabel objects>)
## (array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), <a list of 16 Text major ticklabel objects>)
## (array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), <a list of 16 Text major ticklabel objects>)
## (array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), <a list of 16 Text major ticklabel objects>)
## (array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), <a list of 16 Text major ticklabel objects>)
plt.subplots_adjust(wspace = .1, hspace = 1)